4,731,256 members and growing!   7,545 now online. My Profile | My Settings | My Bookmarks | My Articles | Sign out
All Topics, MFC/C++ >> Internet & Network >> Unedited Reader Contributions

Mobile sms mms / Web Form posting from your exe using minimalistic aproach
By Ladislav Nevery.

Probably simplest way to send web form. Included example to send any text to any mobile phone in world
C++
Windows
Win32, VS, MFC
Dev
Posted: 25 Oct 2006
Views: 13,670
Note: This is an unedited reader contribution Modify | Delete 
Announcements


Search    
Advanced Search
Sitemap
Print Broken Article? Bookmark Discuss Send to a friend
3 votes for this article.
Popularity: 1.33. Rating: 2.78 out of 5.

Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report this article.

Introduction

I got this brand new phone with integrated email client. And as we know mobile email checking costs money.But then I stumbled upon one of those free sms internet gateways. So the idea was to write simple program to check / read email (see my article) and then forward it as sms text to my mobile. But of course nothing keeps you from let's say reading some rss feed or stock value from web and sending it as sms to your mobile. Also there are some mms internet gateways too (like) so you can for example send image from your webcam (see my article) right to your mms capable mobile when you detect movement in your room

Background

Well most of these sms gateways are simple web forms. and some of them require login prior sending. but this is not a problem since this is just another web form.

How to Post Web Form

I tried to find simplest way how to do this. Beware the folowing sample will work just for sending one free sms Save the following code as let's say form.htm. And That's it. Doubleclicking it will send 1 free sms. But before you do so be sure you replace the country phone prefix "421" and mobile phone number "902203302".
// form.htm
<script language="JavaScript"><!--
var input = new Array("user_reg",   "email_reg","mobile_code_reg","mobile_reg","reg");
var value = new Array("HelloWorld", "o@o.o",    "421",            "902203302", "1");

document.write("<body><form name=form method=POST action=http://www.etssms.com/globindex.php?show_page=register>")
for (i in input) document.write("<input type=hidden name="+input[i]+" value="+value[i]+">")
document.write("</form>")

form.submit();
//--></script>

How to do this from your program

Well in any language on any platform just open this htm file(or have it as static string or resource. and replace "Hello World" "421" "902203302" with your values then write it to tmp.htm file and launch it from shell. Voila all proxy negotiation url redirection ssl encryption urlencoding auth cookie and final form size calculation etc. is done by default by web browser transparently for us.
// Windows c++ sample (but there is no problem to do this in let's say perl on Linux)
// replace all values in form.htm to "%s" so sprintf can be used to fill them. For example change "421" to "%s"
// use new mobile number since on this particular gateway each no can be used just once for free

#include <windows.h>
#include <stdio.h>

int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, char* cmd, int show) {
    char  data[2][0x1000]={0}; 
    FILE* file=fopen("form.htm","rb"); fread( data[0],1,sizeof(data[0]),file); fclose(file);
    sprintf(data[1],data[0],"HelloWorld","o@o.o","421","902203301","1");
          file=fopen("send.htm","wb"); fwrite(data[1],1,strlen(data[1]),file); fclose(file);
    ShellExecute(0,"open","send.htm",0,0,SW_HIDE);
}

Place for Improvements

One reason why I din't used internet explorer wininet.dll or browser com hosting is to make this solution multiplatfom and multilanguage. Also latest patches to internet explorer (XP SP2) require interactive confirmation to every javascript in html. One solution is to add localhost to trusted sites in internet explorer security zones options or send 2 mouse clicks to ie window so action is confirmed. I personaly prefer firefox as default browser. Later you will also want to run browser window hidden and close it when finished but that shouldn't be a problem.(will add code for this later)

There are many mobile providers and sms gateways

Just to mention few (agentsms.com SMS.ac, ETS SMS, smsGeezer.com, Bigfoot.com, Weltweite-SMS.de GoogleCalendar) So go and chose one. Next find fields names by viewing page source in browser when there. And finally write new form.htm for this gateway + update your exe to fill this new form

Who is reading this article right now

About Ladislav Nevery


Currently Seeking Job

Past Projects:
[Siemens.sk]Mobile network software: HLR-Inovation for telering.at (Corba)
Medical software: CorRea module for CT scanner
[cauldron.sk]Computer Games:XboxLive/net code for Conan, Knights of the temple II, GeneTroopers, CivilWar, Soldier of fortune II
[www.elveon.com]Computer Games:XboxLive/net code for Elveon [new game based on Unreal Engine 3]

Click here to view Ladislav Nevery's online profile.


Other popular Internet & Network articles:




[Top] Rate this Article for us!     PoorExcellent  
FAQ  Message score threshold    Search comments  
  View    Per page  
New Message Msgs 1 to 11 of 11 (Total: 14) (Refresh) First Prev Next     
Subject  Author  Date 
  problem in writting code   Tusajigwe Isaga  10:04 12 Sep '07 
  hai   vadivelkec  7:58 6 Jun '07 
  hai   vadivelkec  7:56 6 Jun '07 
  Simpler again   xaml.net  8:35 13 Jan '07 
  Simpler alternative approach   daluu  20:49 1 Nov '06 
  Re: Simpler alternative approach   Ladislav Nevery  7:11 4 Nov '06 
  Send message via html form   marlongrech  2:28 26 Oct '06 
  Re: Send message via html form   Ladislav Nevery  2:51 26 Oct '06 
  Re: Send message via html form   marlongrech  2:57 26 Oct '06 
  Re: Send message via html form   timbolicus_prime  12:37 27 Oct '06 
  Re: Send message via html form   marlongrech  13:19 27 Oct '06 
Last Visit: 15:47 Friday 23rd November, 2007 First Prev Next     

General comment    News / Info    Question    Answer    Joke / Game    Admin message


Updated: 25 Oct 2006 Article content copyright Ladislav Nevery, 2006
everything else Copyright © CodeProject, 1999-2007.
Web07 | Advertise on The Code Project | Privacy

The Ultimate ToolboxASP AllianceDeveloper FusionDevelopersdexDevGuruProgrammers HeavenPlanet Source CodeTek-Tips Forums